window.onload = function (){
  var dataObj = document.getElementById("data");
  //得到data对象中，所有tr子元素集合
  var trArray = dataObj.getElementsByTagName("tr");
  for(var i=0;i<trArray.length;i++){
    trArray[i].onclick = function (){
      trClick(this);
    }
  }
}

var colorTr = null;
function trClick(trObj){
  if( colorTr != null){
    colorTr.style.backgroundColor = "white";
  }

  trObj.style.backgroundColor = "red";
  colorTr = trObj;
}